/**
 * 
 */
package pagecode.pages.solicitudes;

import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlInputTextarea;
import javax.faces.component.html.HtmlOutputText;

import org.apache.myfaces.custom.fileupload.HtmlInputFileUpload;

import pagecode.PageCodeBase;

import com.ibm.faces.component.html.HtmlScriptCollector;
import com.stefanini.pe.bbva.iivs.in.model.solicitud.SolicitudModel;

/**
 * @author ocortez
 *
 */
public class ModificarArchivo extends PageCodeBase {

	protected HtmlScriptCollector scriptCollector2;
	protected HtmlOutputText text1;
	protected HtmlInputText text2;
	protected HtmlOutputText text3;
	protected HtmlOutputText text5;
	protected HtmlInputFileUpload flCargaArchivos;
	protected HtmlCommandButton button2;
	protected HtmlCommandButton button1;

	protected SolicitudModel solicitudModel;
	protected HtmlInputTextarea textarea1;

	public SolicitudModel getSolicitudModel() {
		 if (solicitudModel == null) {
			 solicitudModel = (SolicitudModel) getFacesContext().getApplication().createValueBinding("#{solicitudModel}").getValue(getFacesContext());
	        }
		return solicitudModel;
	}

	public void setSolicitudModel(SolicitudModel solicitudModel) {
		this.solicitudModel = solicitudModel;
	}
	
	protected HtmlScriptCollector getScriptCollector2() {
		if (scriptCollector2 == null) {
			scriptCollector2 = (HtmlScriptCollector) findComponentInRoot("scriptCollector2");
		}
		return scriptCollector2;
	}

	protected HtmlOutputText getText1() {
		if (text1 == null) {
			text1 = (HtmlOutputText) findComponentInRoot("text1");
		}
		return text1;
	}

	protected HtmlInputText getText2() {
		if (text2 == null) {
			text2 = (HtmlInputText) findComponentInRoot("text2");
		}
		return text2;
	}

	protected HtmlOutputText getText3() {
		if (text3 == null) {
			text3 = (HtmlOutputText) findComponentInRoot("text3");
		}
		return text3;
	}

	protected HtmlOutputText getText5() {
		if (text5 == null) {
			text5 = (HtmlOutputText) findComponentInRoot("text5");
		}
		return text5;
	}

	protected HtmlInputFileUpload getFlCargaArchivos() {
		if (flCargaArchivos == null) {
			flCargaArchivos = (HtmlInputFileUpload) findComponentInRoot("flCargaArchivos");
		}
		return flCargaArchivos;
	}

	protected HtmlCommandButton getButton2() {
		if (button2 == null) {
			button2 = (HtmlCommandButton) findComponentInRoot("button2");
		}
		return button2;
	}

	protected HtmlCommandButton getButton1() {
		if (button1 == null) {
			button1 = (HtmlCommandButton) findComponentInRoot("button1");
		}
		return button1;
	}

	public String btnAceptarAction() {
		
//		this.getSolicitudModel().getTipoDocumento().setAdjuntarBorrar(true);
//		this.getSolicitudModel().getTipoDocumento().setCargaFile(this.getSolicitudModel().getCargaFile());
//			return "aceptarMod";
//			
		try {
			if (this.getSolicitudModel().getCargaFile()!=null) {
				this.getSolicitudModel().getTipoDocumento().setAdjuntarBorrar(true);
				this.getSolicitudModel().getTipoDocumento().setCargaFile(this.getSolicitudModel().getCargaFile());	
			}	
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
		return "aceptarMod";		
			
			
	}

	public String btnCancelarAction() {
	
		//Put your logic here.
			return "cancelarMod";
	}

	protected HtmlInputTextarea getTextarea1() {
		if (textarea1 == null) {
			textarea1 = (HtmlInputTextarea) findComponentInRoot("textarea1");
		}
		return textarea1;
	}

}